<?php
/**
 * @Copyright Copyright (C) 2010-2012
 * @license GNU/GPL http://www.gnu.org/copyleft/gpl.html
 + Created by:          Webit Solution
 * Company:		Webit Solution
 + Contact:		www.webits.asia, developer@webits.asia
 * Created on:	Mar 21, 2012
 ^
 + Project: 		WRecruit
 * File Name:	views/candidates/tmpl/candidateprofile.php
 ^ 
 * Description: template view candidate profile
 ^ 
 * History:		NONE
 ^ 
 */
 
 defined('_JEXEC') or die('Restricted access');
   global $mainframe;
  $document =& JFactory::getDocument();

  /*$document->addScript( 'components/com_wrecruit/js/jquery-1.7.2.min.js' );
  $document->addScript( 'components/com_wrecruit/js/jquery-ui.min.js' );
  $document->addScript( 'components/com_wrecruit/js/jquery.uniform.js' );
  $document->addScript( 'components/com_wrecruit/js/scripts.js' );*/
  $document->addScript( 'components/com_wrecruit/js/popup.js' );
  $document->addStyleSheet('components/com_wrecruit/css/popup.css');
  $candidate = $this->getModel('wrecruit', 'WRecruitModel');
  $user	=& JFactory::getUser();
  if(isset($user->id) && $user->id == 0 || $user->id == ''){
	   $app =& JFactory::getApplication(); 
	   $app->enqueueMessage( JText::_( 'Please <a href="index.php?option=com_users&view=login">Login</a>' ), 'Login access' );
	  return;
  }else{
  	$candidateObj = $candidate->getAllCandidatesInfor($user->id);
	if( !$candidateObj ){
		$app =& JFactory::getApplication(); 
       //add a message to the message queue
        $app->enqueueMessage( JText::_( 'Please <a href="index.php?option=com_users&view=login">Login</a>' ), 'Login access' );

		return;
	}
	
  }
  
?>

<div class="box-list">			
					<div class="head-title">
						<h2>Update your profile and your account<?php  //print_r( $candidateObj);?></h2>
					</div>
				<form action="<?php echo 'index.php?option=com_wrecruit&c=wrecruit&view=candidates&layout=candidatepanel&Itemid='.JRequest::getVar('Itemid');?>" method="post" name="adminForm" enctype="multipart/form-data">
					<div id="pic-pro">
					 <a href="<?php echo JURI::base();?>index.php?option=com_wrecruit&c=wrecruit&view=candidates&layout=candidateprofile&Itemid=<?php echo JRequest::getVar('Itemid');?>&id=<?php echo $candidateObj->id;?>"
					 title="<?php echo $candidateObj->firstname.' '.$candidateObj->lastname;?>">
					 <?php
					  if(file_exists(JPATH_SITE.DS.'wrecruitdata'.DS.'photo'.DS.$candidateObj->photo)){
					  ?>
						<img height="100" width="100" src="<?php echo JURI::base();?>/wrecruitdata/photo/<?php echo $candidateObj->photo; ?>" 
						alt="<?php echo $candidateObj->firstname." ".$candidateObj->lastname;?>">
					 <?php } ?>
					 </a>
                    </div>
                    <table border="0" width="200px" class="account-browse-pic" >
                        <tr>
                            <td>
                                <input type="file" class="" id="candidate_photo" name="candidate_photo">
                            </td>
                        </tr>
                    </table>
						
					<div class="post-detail-box candidate-wrapper" style="background:none; border:none;">
						
                        	
                            	<table border="0" width="712px" class="candidate_profile_table" cellpadding="1" cellspacing="0">
                                	<tr>
                                    	<td width="48%" style="vertical-align:top; min-height:150px; max-height:150px;">
                                        	<?php /*StartPersonal Info*/?>
                                             <table border="0" id="personal-info" >
                                             	<thead>
                                                <tr>
                                                	<th colspan="2"> <h3>Personal Info</h3></th>
                                                </tr>
                                                </thead>
                                                <tbody>
                                                	<tr>
                                                    	<td><label>First Name</label></td>
                                                        <td><span class="star7">*</span>
                                                        	<input type="text" class="text input-191" value="<?php echo $candidateObj->firstname;?>" name="first_name" />
                    									</td>
                                                    </tr>
                                                    <tr>
                                                    	<td><label>Last Name</label></td>
                                                        <td><span class="star7">*</span>
                                                        	<input type="text" class="text input-191" name="last_name" value="<?php echo $candidateObj->lastname;?>" />
                    									</td>
                                                    </tr>
                                                    <tr>
                                                    	<td><label>Gender</label></td>
                                                        <td>
                                                        	<?php echo $candidateObj->gender;?>
                    									</td>
                                                    </tr>
                                                    <tr>
                                                    	<td><label>Birthday</label></td>
                                                        <td>
                                                        	<?php echo $candidateObj->date['month'];?>&nbsp;&nbsp;&nbsp;&nbsp;
                                                            <?php echo $candidateObj->date['day'];?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                                            <?php echo $candidateObj->date['year'];?>
                    									</td>
                                                    </tr>
                                                    <tr>
                                                    	<td><label>Fields</label></td>
                                                        <td>
                                                        	<?php echo $candidateObj->fields1;?>
                    									</td>
                                                    </tr>
                                                    <tr>
                                                    	<td><label>Education</label></td>
                                                        <td>
                                                            <?php echo $candidateObj->education;?>
                    									</td>
                                                    </tr>
                                                    <tr>
                                                    	<td colspan="2">&nbsp;<br/></td>
                                                    </tr>
                                                
                                                </tbody>
                                             </table>
                                            <?php /*End Personal Info*/?>
                                        </td>
                                        <td>&nbsp;</td>
                                        <td width="48%" style="vertical-align:top; min-height:150px; max-height:150px;">
                                        <?php /*Start Contact Info*/?>
                                             <table border="0" style="height: 150px;">
                                             	<thead>
                                                 <tr>
                                                	<th colspan="2"><h3> Contact Info</h3></th>
                                                 </tr>
                                                </thead>
                                                <tbody>
                                                	<tr>
                                                    	<td><label>Phone</label></td>
                                                        <td>
                                                        	<input type="text" class="text input-191" value="<?php echo $candidateObj->phone;?>" name="phone" />
                    									</td>
                                                    </tr>
                                                    <tr>
                                                    	<td><label>Email</label></td>
                                                        <td>
                                                        	<?php echo $candidateObj->EMAIL;?>
                    									</td>
                                                    </tr>
                                                    <tr>
                                                    	<td><label>Country</label></td>
                                                        <td>
                                                        	
                                                            <?php 
																echo $candidateObj->country;
															?>
                    									</td>
                                                    </tr>
                                                    <tr>
                                                    	<td>
                                                        	<label>City</label></td>
                                                        <td>
                                                        	<input type="text" class="text input-191" value="<?php echo $candidateObj->city;?>" name="city" />
                    									</td>
                                                    </tr>
                                                    <tr>
                                                    	<td><label>Address</label></td>
                                                        <td>
                                                        	<textarea name="address" id="address-text-area" rows="80"><?php echo trim($candidateObj->address);?></textarea>
                                                            <p style="margin:0; padding:0;">&nbsp;</p>
                    									</td>
                                                    </tr>
                                                   
                                                  
                                                </tbody>
                                             </table>
                                            <?php /*End Contact Info*/?>
                                        </td>
                                    </tr>
                                    <tr>
                                    	<td colspan="3"> 
                                        	<?php /*Account Info*/?>
					
                                             <table border="0" width="100%" class="account-info" >
                                             	<thead>
                                                <tr>
                                                	<th colspan="2"> <h3>Account Info</h3></th>
                                                </tr>
                                                </thead>
                                                <tbody>
                                                	<tr><td colspan="2">&nbsp;</td></tr>
                                                	<tr>
                                                    	<td class="candidate-text">Your logged in with this Email address: <a href="#"  ><?php echo $candidateObj->EMAIL;?></a></td>
                                                        <td class="float-right"><a href="#" style="text-decoration:underline; cursor:pointer;" class="wpopup" id="email">Change your email address?</a></td>
                                                    </tr>
                                                    <tr>
                                                    	<td>&nbsp;</td>
                                                        <td class="float-right"><a href="#" style="text-decoration:underline; cursor:pointer;" class="wpopup" id="password">Change your password?</a></td>
                                                    </tr>
                                                    <tr>
                                                    	<td>Your account: <?php if($candidate->isVacancyInterrest($candidateObj->id)){ echo "Premium";}else{ echo "Basic";}?></td>
                                                        <td class="float-right"><a href="<?php echo JURI::base()."index.php?option=com_wrecruit&c=wrecruit&view=candidates&layout=upgradeaccount&Itemid=".JRequest::getVar('Itemid');?>" style="text-decoration:underline; cursor:pointer;" class="" id="package">Upgrade your account?</a></td>
                                                    </tr>
                                                    <tr>
                                                    	<td>&nbsp;</td>
                                                        <td class="float-right"><a href="#" href="#" style="color: #b5b5b5;">Learn more about account packages and banifits</a></td>
                                                    </tr>
                                                  <!--  <tr>
                                                        <td colspan="2"><span style="text-decoration:underline; cursor:pointer;" class="wpopup" id="post-cv-leading-page">Post cv leading page</span></td>
                                                    </tr>-->
                                                    
                                                </tbody>
                                             </table>
                                            <?php /*End account Info*/?>
                                        </td>
                                       
                                   </tr>
								   
                                   <tr>
                                   		<td colspan="3">
                                        <?php if($candidate->isVacancyInterrest($candidateObj->id)){?>
                                        <?php /*Account Info*/?>
                                             <table border="0" width="100%" class="account-info" >
                                             	<thead>
                                                <tr>
                                                	<th colspan="3"> <h3>Vacancy Interest</h3></th>
                                                </tr>
                                                </thead>
                                                <tbody>
                                                	<tr>
                                                    	<td class="candidate-text"><label>Position: </label></td><td>
														<input type="text" value="<?php echo trim($candidateObj->vacancy_interest_position);?>" name="position">
														
                                                  	  </select></td>
                                                        <td style="padding-left:70px;"><label>Fields: </label>
                                                          <?php 
														     //echo $candidateObj->fields2;
															 $fieldIds = $candidate->getVacancyFieldByCandidateId($candidateObj->id);
														     echo $candidate->getFieldList(false,$fieldIds,'data-placeholder="Choose any field..." multiple class="chzn-select" style="width:230px; height:14px; border: 1px solid #e8e8e8;"',"field[]");
														  ?>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                    	<td>
                                                        	<label>Skills: </label></td><td colspan="2">
															<?php 
															  $document->addStyleSheet('components/com_wrecruit/css/chosen/chosen.css');
															  $skillIds = $candidate->getVacancySkillByCandidateId($candidateObj->id);
															  echo $candidate->getSkillList(false,$skillIds,'data-placeholder="Choose any skill..." multiple class="chzn-select" style="width:604px; height:22px; border: 1px solid #e8e8e8;"',"skill[]");
															?>
															<script src="components/com_wrecruit/js/chosen/chosen.jquery.js" type="text/javascript"></script>
															<script type="text/javascript"> 
																jQuery(".chzn-select").chosen(); 
																jQuery(".chzn-select-deselect").chosen({allow_single_deselect:true}); 
															</script>
													    </td>
                                                    </tr>
                                                    <tr>
                                                    	<td> <label>Salary: </label></td><td> 
														  <?php echo trim($candidateObj->salaryRange);?>
                                                  	  </select></td>
                                                        <td class="float-right">&nbsp;</td>
                                                    </tr> 
                                                </tbody>
                                             </table>
                                            <?php /*End account Info*/ ?>
                                            <?php } ?>
                                            
                                            <table border="0" width="100%" id="account-button">
                                            	<tr>
                                                	<td width="135px">
                                                        <div class="wrapp-btn">
                                                            <span class="btn-left"><span class="btn-right"><input type="submit" value="Cancel" id="cancelthis" class="btn"/>&nbsp;</span></span>
                                                       </div>
                                           			</td>                                              
                                                	<td>
                                                        <div class="wrapp-btn">
                                                            <span class="btn-left"><span class="btn-right"><input type="submit" value="Save Change Now" id="savethis" class="btn"/>&nbsp;</span></span>
                                                       </div>
                                           			</td>
                                                </tr>
                                             </table>                                         
                                        </td>
                                   </tr>
							
                                </table>
                                <input type="hidden" value="<?php echo $candidateObj->id;?>" name="id">
                                <input type="hidden" value="candidatepanel" name="layout">
                                <input type="hidden" value="com_wrecruit" name="option">
                                <input type="hidden" value="addCandidate" name="task">
                            
                       
					</div>
				</form>
				</div>
				
        <!--popup content-->
        <div id="popupContainer" class="hidden" style="text-align:left;">
            <a id="close" class="hidden" title="close popup"></a>   
            <center>
            <form action="index.php" method="post">
            <table border="0">
            	<tr>
                	<td><input type="text" class="text" value="<?php echo $candidateObj->EMAIL;?>" name="mails" /></td>
                    <td></td>
                </tr>
                <tr>
                	<td colspan="2" align="right"> 
                    	<div class="wrapp-btn">
                            <span class="btn-left"><span class="btn-right"><input type="submit" value="Save"  class="btn"/>&nbsp;</span></span>
                       </div>
					</td>
                </tr>
            </table>
            </form>
            </center>
             
        </div>
        <div id="overlayEffect">
        </div>
       <!--end popup content--> 
<script type="text/javascript">
	
</script>
